/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.mwas.proteana.geneontology;

import java.util.ArrayList;
import java.util.Objects;
import pl.mwas.proteana.geneontology.util.Relation;

/**
 *
 * @author mateusz.was
 */
public class GOTerm {
    
    private final String id;
    private final String name;
    private final String namespace;
    
    private final boolean isAnonymous;
    private final ArrayList<String> altIds;
    private final String def; //add dbxref?
    private final String comment;
    private final ArrayList<String> subsets;
    private final ArrayList<String> synonyms; //add dbxref and category?
    private final ArrayList<String> xRef;
    
    private final ArrayList<Relation> relationships;
    
    private final boolean obsolete;
    private final ArrayList<GOTerm> replacedBy;
    private final ArrayList<GOTerm> consider;
    
    private final String createdBy;
    private final String creationDate;
    
    private boolean valid;
    
    public GOTerm(String id, String name, String namespace, boolean isAnonymous, ArrayList<String> altIds, String def, String comment, ArrayList<String> subsets, ArrayList<String> synonyms, ArrayList<String> xRef, ArrayList<Relation> relationships, boolean isObsolete, ArrayList<GOTerm> replacedBy, ArrayList<GOTerm> consider, String createdBy, String creationDate) {
        this.id = id;
        this.name = name;
        this.namespace = namespace;
        this.isAnonymous = isAnonymous;
        this.altIds = altIds;
        this.def = def;
        this.comment = comment;
        this.subsets = subsets;
        this.synonyms = synonyms;
        this.xRef = xRef;
        this.relationships = relationships;
        this.obsolete = isObsolete;
        this.replacedBy = replacedBy;
        this.consider = consider;
        this.createdBy = createdBy;
        this.creationDate = creationDate;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getNamespace() {
        return namespace;
    }

    public boolean isIsAnonymous() {
        return isAnonymous;
    }

    public ArrayList<String> getAltIds() {
        return altIds;
    }

    public String getDef() {
        return def;
    }

    public String getComment() {
        return comment;
    }

    public ArrayList<String> getSubsets() {
        return subsets;
    }

    public ArrayList<String> getSynonyms() {
        return synonyms;
    }

    public ArrayList<String> getxRef() {
        return xRef;
    }

    public ArrayList<Relation> getRelationships() {
        return relationships;
    }

    public boolean isObsolete() {
        return obsolete;
    }

    public ArrayList<GOTerm> getReplacedBy() {
        return replacedBy;
    }

    public ArrayList<GOTerm> getConsider() {
        return consider;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public String getCreationDate() {
        return creationDate;
    }
    
    public boolean hasOtherRelations() {
        if(relationships == null) return false;
        return !relationships.isEmpty();
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GOTerm other = (GOTerm) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    public void replaceRelation(Relation toDel, Relation toInsert) {
        relationships.contains(toDel);
        relationships.remove(toDel);
        relationships.add(toInsert);
    }
    
}
